<template>
	<view>

		<view class="goodslist-item">
			<view class="goodslist-left">
				<radio :checked="goods.goods_state" color="#C00000" v-if="showRadio" @click="radioChangeHandler">
				</radio>
				<img :src="goods.goods_small_logo || defaultPic" class="goodslist-img" />
			</view>
			<view class="goodslist-right">
				<view class="goodslist-title">{{goods.goods_name}}</view>
				<view class="goodslist-price-box">
					<view class="goodslist-price">￥{{parseFloat(goods.goods_price).toFixed(2)}}</view>
					<uni-number-box :min="1" :value="goods.goods_count" v-if="showNum" @change="numberChangeHandler"></uni-number-box>
				</view>

			</view>
		</view>


	</view>
</template>

<script>
	export default {
		props: {
			goods: {
				type: Object,
				default: {}
			},
			//是否展示左侧的radio
			showRadio: {
				type: Boolean,
				default: false
			},
			//是否展示右侧的Number组件
			showNum: {
				typy: Boolean,
				default: false
			}
		},
		data() {
			return {
				defaultPic: 'https://img95.699pic.com/photo/60078/6443.jpg_wh860.jpg'
			};
		},
		methods: {
			radioChangeHandler() {
				this.$emit('radio-click', {
					goods_id: this.goods.goods_id,
					goods_state: !this.goods.goods_state
				})
			},
			numberChangeHandler(val){
				
				this.$emit('num-change',{
					goods_id: this.goods.goods_id,
					goods_count: +val
					
				})
			}
		}
	}
</script>

<style lang="scss">
	.goodslist-item {
		width: 750rpx;
		box-sizing: border-box;
		display: flex;
		padding: 10px 5px;
		border-bottom: 1px solid #f0f0f0;

		.goodslist-left {
			margin-left: 5px;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.goodslist-img {
				width: 100px;
				height: 100px;
				display: block;
			}

		}

		.goodslist-right {
			display: flex;
			flex: 1;
			flex-direction: column;
			justify-content: space-between;
			padding: 0 5px;

			.goodslist-title {
				font-size: 13px;
			}

			.goodslist-price-box {
				display: flex;
				justify-content: space-between;
				align-items: center;
				
				.goodslist-price {
					font-size: 13px;
					color: #c00000;
				}
			}

		}
	}
</style>